var events = require("events"); //原生模块(HTTP, fs, path, events, util)

var Emitter = events.EventEmitter; //构造函数
var eventObj = new Emitter(); //事件对象实例化

eventObj.on("sayhello", function(){
    console.log("hello world");
}) //事件监听(事件名，回调函数)

setTimeout(()=>{
    eventObj.emit("sayhello"); //emit 事件触发，调用sayhello方法
},3000)